home *** CD-ROM | disk | FTP | other *** search
- Path: service-2.agate.net!usenet
- From: ettienne@agate.net (Steve Nutt)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ guru sought ...
- Date: Sat, 20 Apr 1996 05:07:30 GMT
- Organization: DET
- Message-ID: <4l9k16$mbo@service-2.agate.net>
- References: <316CB5B5.41C6@cs.york.ac.uk>
- Reply-To: ettienne@agate.net
- NNTP-Posting-Host: ettienne.sdi.agate.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- John Kennedy <johnk@cs.york.ac.uk> wrote:
-
- >Hi there,
-
- >I have an interesting C++ problem that I was wondering if any guru out
- >there knows the answer to....
-
- >I am trying to create a template class that saves or reads data to/from
- >a file. This is not a problem for numeric data as fstream can cope with
- >this no problem. The problem I have is that when the template type is a
- >string I have to create the space to store the data in. The only way I
- >can see of doing this is to use a case statement in the template
- >function but this is then removing all purpose of creating a template in
- >the first place.
-
- >Does anyone know a way around this problem ?
-
- >John Kennedy
-
- >johnk@cs.york.ac.uk
-
- I don't think I quite follow the problem here. Why do you need the
- case statement?
-
- I've used a class similar to
-
- template <size_t size> class _export TString
- {
- public:
- TString (void)
- {
- c[0] = 0;
- }
-
- TString (const TString <size>& other)
- {
- strcpy (c, other.c);
- }
-
- private:
-
- char c[size +1];
- };
-
- when I've not wanted to use the Borland string class.
-
- Steve
-
-